package com.lizhi.menu.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lizhi.menu.Dto.AttentionDto;
import com.lizhi.menu.domain.Attention;
import com.lizhi.menu.mapper.AttentionMapper;
import com.lizhi.menu.service.IAttentionService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 关注信息中间Service业务层处理
 *
 * @author lizhi
 * @date 2023-05-18
 */
@Service
@RequiredArgsConstructor
public class AttentionServiceImpl implements IAttentionService {
    private final AttentionMapper attentionMapper;

    /**
     * 查询关注信息中间列表
     *
     * @param dto 关注信息中间
     * @return 关注信息中间
     */
    @Override
    public Page<Attention> list(AttentionDto dto) {
        return attentionMapper.selectAttentionList(dto.createPage(),dto);
    }

    /**
     * 新增关注信息中间
     *
     * @param attention 关注信息中间
     * @return 结果
     */
    @Override
    public void add(Attention attention) {
        attentionMapper.insert(attention);
    }

    /**
     * 修改关注信息中间
     *
     * @param attention 关注信息中间
     * @return 结果
     */
    @Override
    public void edit(Attention attention) {
        attentionMapper.updateAttention(attention);
    }

    /**
     * 批量删除关注信息中间
     *
     * @param userIds 需要删除的关注信息中间主键
     * @return 结果
     */
    @Override
    public void remove(List<String> userIds) {
        attentionMapper.deleteAttentionByUserIds(userIds);
    }

    /**
     * 删除关注信息中间信息
     *
     * @param userId 关注信息中间主键
     * @return 结果
     */
    @Override
    public void remove(String userId) {
         attentionMapper.deleteById(userId);
    }
}
